﻿using MainApplication.DataContext;
using MainApplication.DataEntry;
using Microsoft.EntityFrameworkCore;           // 异步扩展方法
using MainApplication.DataEntry;
using MainApplication.Services;
namespace MainApplication.Services
{
    public class StudentService
    {
        private readonly TeachDbContext _context;

        public StudentService(TeachDbContext context)
        {
            _context = context;
        }

        public async Task<List<Student>> GetStudentsPagedAsync(int pageNumber, int pageSize)
        {
            return await _context.Students
                .OrderBy(s => s.StudentId)
                .Skip((pageNumber - 1) * pageSize)
                .Take(pageSize)
                .ToListAsync();
        }
    }
}
